package com.zhx.threadcoreknowledge.background;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-05 10:13
 * 用途         ： TODO
 */
public class MultiThreadError3 {

    private Map<String,String> stringStringMap;

    public MultiThreadError3() {
        this.stringStringMap = new HashMap<>();
        stringStringMap.put("1","周一");
        stringStringMap.put("2","周二");
        stringStringMap.put("3","周三");
        stringStringMap.put("4","周四");
        stringStringMap.put("5","周五");
        stringStringMap.put("6","周六");
        stringStringMap.put("7","周七");
    }

    public Map<String,String> getStates(){
        return stringStringMap;
    }

    public Map<String,String> getStatesImproved(){
        return  new HashMap<>(stringStringMap);
    }

    public static void main(String[] args) {
        MultiThreadError3 multiThreadError3 = new MultiThreadError3();
        Map<String, String> stringStringMap = multiThreadError3.getStatesImproved();
        System.out.println(stringStringMap.get("1"));
        stringStringMap.remove("1");
        System.out.println(stringStringMap.get("1"));
    }
}
